<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<!-- <script src='/Public/jquery.min.js'></script> -->
  <script src="https://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
  
	<script src='/Public/foundation/js/foundation.min.js'></script>
	<link rel="stylesheet" href="/Public/foundation/css/foundation.min.css">
  <script src='/Public/jquery.cityselect.js'></script>
  <script src='/Public/jquery.datetimepicker.full.js'></script>
  <link rel="stylesheet" href="/Public/jquery.datetimepicker.css">
   <script src="http://cdn.static.runoob.com/libs/foundation/5.5.3/js/vendor/modernizr.js"></script>
    <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<nav class="top-bar" data-topbar>
  <ul class="title-area">
    <li class="name">
      <h1><a href="#">后台管理</a></h1>
    </li>
  </ul>

  <section class="top-bar-section">
    <ul class="right">
      <li><a href=""><?php echo (session('name')); ?></a></li>
      <li><a href="<?php echo U('Login/doLogout');?>">退出</a></li>
    </ul>
  </section>
</nav>

<div class="small-2 columns">
<ul class="side-nav">
 <?php if(is_array($nav)): $i = 0; $__LIST__ = $nav;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><li><a href="<?php echo U($vo['url']);?>" target='<?php echo ($vo["target"]?"_blank":null); ?>'><?php echo ($vo["mname"]); ?></a></li><?php endforeach; endif; else: echo "" ;endif; ?>
    </ul>
</div>
<div class="small-10 columns">

	<div class="row">
	<form action="?" method="post" id='form'>
		<div class="medium-4 columns">
			<select name="up" id="sItem">
				<?php if(is_array($b)): $i = 0; $__LIST__ = $b;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$examType): $mod = ($i % 2 );++$i;?><option value="<?php echo ($examType["id"]); ?>"><?php echo ($examType["exam_name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
			</select>
		</div>
		<div class="medium-4 columns">
			<select name="term_id" id="term">
				<?php if(is_array($term)): $i = 0; $__LIST__ = $term;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$term): $mod = ($i % 2 );++$i;?><option value="<?php echo ($term["val"]); ?>"><?php echo ($term["val"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
			</select>
		</div>
		<input type="submit">
	</form>	
	</div>
	<div class='row' id='examTable'>
	<form id='mark' method='post' action=<?php echo U('doAddExam');?>>
	<table contenteditable="true" class='medium-12 columns'>
	<thead>
	<tr>
					<th>姓名</th>
					<?php if(is_array($item)): $i = 0; $__LIST__ = $item;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$articleTitle): $mod = ($i % 2 );++$i;?><th><?php echo ($articleTitle["exam_name"]); ?></th><?php endforeach; endif; else: echo "" ;endif; ?>
				</tr>
				</thead>
				<tbody>
				<?php if(is_array($student)): $i = 0; $__LIST__ = $student;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$studentInfo): $mod = ($i % 2 );++$i;?><tr index='<?php echo ($studentInfo["student_id"]); ?>'>
					<th><?php echo ($studentInfo["sname"]); ?></th>
					<?php if(is_array($item)): $i = 0; $__LIST__ = $item;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$articleTitle): $mod = ($i % 2 );++$i;?><td><input id='<?php echo ($articleTitle["id"]); ?>' type='text'></td>	
						<input type='hidden' name='json' id='json'><?php endforeach; endif; else: echo "" ;endif; ?>
					</tr><?php endforeach; endif; else: echo "" ;endif; ?>
				</tbody>
	</table>
	<input type='button' value='提交' onclick='tj()'>
	</form>
	</div>
	<script>
	function tj(){
		tijiao();
	}
	
	var str='';
	function tijiao(){
	$('tbody tr').map(function(){
			
		var a=$(this).attr('index');
		//console.log($(this).find('th').html());
		$(this).find('td').map(function(){

			var b=$(this).find('input').val();
			var c=$(this).find('input').prop('id');
			str ='{"student_id":'+a+',"score":"'+b+'","type_dict_id":'+c+'}';
			//str = JSON.stringify(arr[index]);
			obj = $('<input type="hidden" name="val[]">').val(str);;
			$('form').append(obj);	
		});
		
	});
	//console.log(typeof(str));
		$('#mark').submit();
	}
	</script> 

	

</div>

</body>
</html>